package com.yunhe.energy.repository.data;

import com.yunhe.energy.domain.data.ElectricityMonth;
import com.yunhe.energy.domain.data.pk.ElectricityPK;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 电量数据仓库
 * @desc 电量数据仓库，按月统计
 * @author liuronglei
 */
@Repository
public interface ElectricityMonthRepository extends JpaRepository<ElectricityMonth, ElectricityPK> {

    /**
     * 查询全部电量对象
     * @param spec 查询条件
     * @param pageable 分页对象
     */
    Page<ElectricityMonth> findAll(Specification<ElectricityMonth> spec, Pageable pageable);

    /**
     * 查询全部价格对象
     * @param spec 查询条件
     * @param sort 排序对象
     */
    Iterable<ElectricityMonth> findAll(Specification<ElectricityMonth> spec, Sort sort);

    /**
     * 查询全部价格对象
     * @param spec 查询条件
     */
    Iterable<ElectricityMonth> findAll(Specification<ElectricityMonth> spec);

//    @Query("select e from ElectricityMonth e where e.deviceId in :deviceIds and e.dtime = :queryDate order by t.val desc")
//    Iterable<ElectricityMonth> getCompanySort(@Param("devCode") List<Long> deviceIds, @Param("queryDate") Date queryDate);

    Page<ElectricityMonth> findByDtimeAndDeviceIdIn(Date dtime, List<Long> deviceIds, Pageable pageable);
}
